package com.atguigu.spzx.manager.service.Impl;

import com.atguigu.spyx.model.common.com.atguigu.spyx.model.entity.product.ProductSpec;
import com.atguigu.spzx.manager.mapper.ProductSpecMapper;
import com.atguigu.spzx.manager.service.ProductSpecService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LT
 * @create 2023-11-09-15:47
 */
@Service
public class ProductSpecServiceImpl implements ProductSpecService {

    @Resource
    ProductSpecMapper productSpecMapper;

    @Override
    public PageInfo<ProductSpec> page(Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum,pageSize);
        List<ProductSpec> list = productSpecMapper.findAll();
        PageInfo<ProductSpec> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void deleteById(Long id) {
        productSpecMapper.deleteById(id);
    }

    @Override
    public ProductSpec getById(Long id) {
        ProductSpec productSpec = productSpecMapper.getById(id);
        return productSpec;
    }

    @Override
    public void updateById(ProductSpec productSpec) {
        productSpecMapper.updateById(productSpec);
    }

    @Override
    public void save(ProductSpec productSpec) {
        productSpecMapper.save(productSpec);
    }

    @Override
    public List<ProductSpec> findAll() {
        return productSpecMapper.findAll();
    }
}
